#!/usr/bin/env python

from sqlalchemy import *
from sqlalchemy.orm import *
from datetime import datetime
Session = scoped_session(sessionmaker(autoflush=True, transactional=True))
meta = MetaData()
mapper = Session.mapper

user_table = Table('user', meta,
                   Column('user_id', Integer, primary_key=True),
                   Column('nickname', String(40), unique=True),
                   Column('profile', UnicodeText),
                   Column('email', Unicode(255), unique=True),
                   Column('created', DateTime, default=datetime.now),
                   Column('updated', DateTime, default=datetime.now))

openid_table = Table('openid', meta,
                     Column('openid_id', Integer, primary_key=True),
                     Column('user_id', Integer, ForeignKey('user.user_id')),
                     Column('passurl', String('255'), unique=True))

class User(object):
    pass

class OpenID(object):
    pass

mapper(User, user_table)
mapper(OpenID, openid_table,
       properties={'user':relation(User, backref="openids")})
